﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ClusteringProblem.Maths.Metrics
{
    public class MinkowskiDistance : IDistance
    {
        public double ComputeDistance(Model.IVectorType x, Model.IVectorType y)
        {
            int vectorLength = x.Vector.Count();
            double distance = 0.0;

            for (int i = 0; i < vectorLength; ++i)
            {
                distance += Math.Pow(x.Vector[i] - y.Vector[i], vectorLength);
            }

            return Math.Pow(distance, 1.0 / vectorLength);
        }
    }
}
